export default class BaseSort{
    constructor(){
        // super(data); 继承的子类才有要求
        this.data = [];// 总数组
        this.result = []; //保存排序结果
        this.loopTimes = 0; //循环多少次
        this.exchangeTimes = 0; //移动交互多少次
        this.compareTimes = 0;//比较了多少次
    }

    start(){ //开始，该部分保护计算时间
        // var beginTime = +new Date();
        // this.sort();
        // var endTime = +new Date();
        // console.log("排序用时共计"+(endTime-beginTime)+"ms");

        console.time("总耗时");
        this.sort();
        console.timeEnd("总耗时");
    }

    // 排序
    sort(){ 
        // TODO
    }

    // 更新比较次数
    updateCompareTimes(){
        this.compareTimes++;
    }

    // 更新移动交换次数
    // offset变化量
    updateExchangeTimes(offset){
        this.exchangeTimes+=offset;
    }

    // 更新循环次数
    updateLoopTimes(){
        this.loopTimes++;
    }

    display(){ //展现结果
        console.log("ResultSort:",this.getResult());
        console.log("LoopTimes:",this.getLoopTimes());
        console.log("CompareTimes:",this.getCompareTimes());
        console.log("ExchangeTimes:",this.getExchangeTimes());
    }
    // ====================================公用部分
    setData(data){ //设置数组
        this.data = data;
    }

    getData(){ //获取数组
        return this.data;
    }
    setResult(result){//设置结果
        this.result = result;
    }

    getResult(){//获取结果
        return this.result;
    }

     setLoopTimes(times){//循环多少次
        this.loopTimes = times;
     }
     getLoopTimes(){
         return this.loopTimes;
     }

     setExchangeTimes(times){//移动交换多少次
        this.exchangeTimes = times;
     }
     getExchangeTimes(){
         return this.exchangeTimes;
     }

     setCompareTimes(times){//比较了多少次
        this.compareTimes = times;
     }
     getCompareTimes(){
         return this.compareTimes;
     }
    // ====================================公用部分
}

